﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MadProps.Validation
{
    public class ValidationResult
    {
        public bool IsValid { get; private set; }
        public IEnumerable<string> Messages { get; private set; }

        private ValidationResult(bool isValid)
            : this(isValid, null)
        {
        }

        private ValidationResult(bool isValid, IEnumerable<string> messages)
        {
            this.IsValid = isValid;
            this.Messages = messages.EmptyIfNull();
        }

        public static ValidationResult Success()
        {
            return new ValidationResult(true);
        }

        public static ValidationResult Error(IEnumerable<string> messages)
        {
            return new ValidationResult(false, messages);
        }
    }
}
